/**
 * 配置该文件可以参考:
 * https://cli.vuejs.org/zh/config/#%E7%9B%AE%E6%A0%87%E6%B5%8F%E8%A7%88%E5%99%A8
 *
 */

// 基础路径，发布前修改这里,当前配置打包出来的资源都是相对路径
let publicPath = './'

const {
  defineConfig
} = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  // lint检查
  lintOnSave: false,
  productionSourceMap: false,

  publicPath: publicPath,
  // 打包后的目录名称
  outputDir: 'dist',
  css: {
    // 忽略 CSS order 顺序警告
    extract: {
      ignoreOrder: true
    },
    loaderOptions: {
      // 引入全局样式
      sass: {
        prependData: `@import "@/style/common.scss";`
      }
    }
  },
  // 处理js文件等
  configureWebpack: {
    optimization: {
      splitChunks: {
        chunks: 'all',
        minSize: 40000,
        maxSize: 0,
        minChunks: 1,
        maxAsyncRequests: 30,
        maxInitialRequests: 30,
        automaticNameDelimiter: '~',
        cacheGroups: {
          vendor: {
            test: /[\\/]node_modules[\\/]/,
            name: 'chunk-vendors',
            chunks: 'all',
            priority: -10,
          },
          common: {
            name: 'chunk-common',
            minChunks: 2,
            chunks: 'all',
            priority: -20,
            reuseExistingChunk: true,
          },
        },
      }
    },
  },
  // 配置转发代理
  devServer: {
    port: 8081,
    proxy: {
      '/': {
        ws: false,
        // 本地环境
        // target: 'http://47.108.186.81:8099/',
        target: 'https://manage.youdianstar.vn',
        logLevel: 'debug', // 显示详细代理日志
        changeOrigin: true,
        pathRewrite: {
          '^/': ''
        }
      }
    },
    client: {
      overlay: false
    }
  }
})